package com.designpattern.BuilderPattern;

/**
 * @Author yp
 * @Date 2021-06-04
 * @Description Builder（抽象建造者）
 *              建一个Product对象的各个部件指定的抽象接口。
 **/

public abstract class MealBuilder {

    Meal meal = new Meal();

    public abstract void buildFood();

    public abstract void buildDrink();

    public Meal getMeal(){
        return meal;
    }
}

/**
 * ConcreteBuilder（具体建造者）
 * 实现抽象接口，构建和装配各个部件。
 */
class MealA extends MealBuilder{

    public void buildDrink() {
        meal.setDrink("可乐");
    }

    public void buildFood() {
        meal.setFood("薯条");
    }

}

/**
 * ConcreteBuilder（具体建造者）
 * 实现抽象接口，构建和装配各个部件。
 */
class MealB extends MealBuilder{

    public void buildDrink() {
        meal.setDrink("柠檬果汁");
    }

    public void buildFood() {
        meal.setFood("鸡翅");
    }

}